import 'package:flutter/material.dart';
import 'package:lazy_data_table/lazy_data_table.dart';
import 'package:ribo_base_core/base_models/base_chart_table_model.dart';

class BaseChartTable extends StatefulWidget {
  BaseChartTable({Key key, @required this.model}) : super(key: key);
  final BaseChartTableModel model;

  @override
  _BaseChartTableState createState() => _BaseChartTableState();
}

class _BaseChartTableState extends State<BaseChartTable> {

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        width: widget.model?.tableDimensions.cellWidth * widget.model?.columns.length + widget.model?.tableDimensions.rowHeaderWidth,
        height: widget.model?.tableDimensions.cellHeight * widget.model?.rows.length + widget.model?.tableDimensions.columnHeaderHeight,
        child: LazyDataTable(
              rows: widget.model?.rows.length,
              columns: widget.model?.columns.length,
              tableTheme: widget.model?.tableTheme,
              tableDimensions: widget.model?.tableDimensions,
              columnHeaderBuilder: widget.model?.columnHeaderBuilder,
              rowHeaderBuilder: widget.model?.rowHeaderBuilder,
              dataCellBuilder: widget.model?.dataCellBuilder,
              cornerWidget: widget.model?.tableHeaderWidget,
            ));
  }
}
